﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Fixx.Connector;

namespace FixxVS
{
	public partial class DisplaySettings : UserControl
	{
		public delegate void DisplayChangedHandler(object sender, DisplaySettingsChangeArgs ca);
		public event DisplayChangedHandler Change = delegate { };

		private FixxPersistantStorage _Store { get; set; }
		private bool Initialized { get; set; }

		public DisplaySettings()
		{
			InitializeComponent();
		}

		private void DisplaySettings_Load(object sender, EventArgs e)
		{
			var store = new FixxPersistantStorage();
			if (store != null && store.Repository != null && store.Repository.FixxSettings != null)
			{
				var fs = (FixxVSSettings)store.Repository.FixxSettings;
				this.cbPrettyPrintDates.Checked = fs.IsUsingPretyDateFormater;
				this._Store = store;
				this.Initialized = true;
			}
		}
		private void ThrowChangedEvent()
		{
			if (!this.Initialized)
				return;

			this.Change(this, new DisplaySettingsChangeArgs()
			{
				IsUsingPretyDateFormater = this.cbPrettyPrintDates.Checked
			});
		}
		private void cbPrettyPrintDates_CheckedChanged(object sender, EventArgs e)
		{
			this.ThrowChangedEvent();
		}
	}
}
